package top.lidee.common.service.twice.management.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import top.lidee.common.service.twice.management.MtStoreFilaService;
import top.lidee.framework.result.PageUtils;
import top.lidee.module.backendApi.twice.page.Query;
import top.lidee.repository.mapper.twice.management.MtStoreFilaMapper;
import top.lidee.repository.model.twice.pojo.management.MtStoreFilaEntity;

import static top.lidee.utils.MapParamsUtil.getKey;


@Service("mtStoreFilaService")
public class MtStoreFilaServiceImpl extends ServiceImpl<MtStoreFilaMapper, MtStoreFilaEntity> implements MtStoreFilaService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<MtStoreFilaEntity> page = this.page(
                new Query<MtStoreFilaEntity>().getPage(params),
                new QueryWrapper<MtStoreFilaEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils searchAllStatusInfo(Map<String, Object> params) {

        //法人/店铺名称/手机号码
        String key = getKey(params);

        LambdaQueryWrapper<MtStoreFilaEntity> wrapper = Wrappers.<MtStoreFilaEntity>lambdaQuery()
                .like(StrUtil.isNotBlank(key), MtStoreFilaEntity::getContact, key)
                .or().like(StrUtil.isNotBlank(key), MtStoreFilaEntity::getName, key)
                .or().eq(StrUtil.isNotBlank(key), MtStoreFilaEntity::getPhone, key);

        IPage<MtStoreFilaEntity> page = this.page(
                new Query<MtStoreFilaEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }
}